package service;

import dao.AttractionDao;
import entity.Attraction;
import org.w3c.dom.Attr;

import java.util.List;

public class AttractionService {
    private AttractionDao attractionDao = new AttractionDao();

    /**
     * 添加景点
     */
    public int addAttraction(Attraction attraction){
        return attractionDao.add(attraction);
    }

    /**
     * 查询所有景点简略信息
     */
    public List<Attraction> selectAll(){
        String sql = "select id,name,price,address,opening_hours,picture_url from attraction where status='发布'";
        return attractionDao.query(sql);
    }

    public Attraction selectById(int id){
        String sql = "select name,rating,price,address,opening_hours,introduce,picture_url from attraction where id=?";
        List<Attraction> attractions = attractionDao.query(sql, id);
        return attractions.get(0);
    }
}
